use MicroStrategy_Views
go


select      a11.CompanyNumber  CompanyNumber,
                a11.DocumentType  DocumentType,
                a11.Subsidiary  Subsidiary,
                a11.Object  Object,
                a11.BusinessUnitID  BUnitID,
                max(a12.BusinessUnit)  BusinessUnit,
                max(a12.BusinessUnitCode)  BusinessUnitCode,
                a11.ExplanationDescription  ExplanationDescription,
                a11.DocumentNumber  DocumentNumber,
                sum(a11.Amount)  WJXBFS1
from         GL_Star_FactsDetails           a11
                join          Common_Star_BusinessUnit a12
                  on          (a11.BusinessUnitID = a12.BusinessUnitID)
                join          Common_Star_Dates             a13
                  on          (a11.GLDateID = a13.CompanyDateID)
where      (a11.CompanyNumber = '00800'
 and a11.LedgerTypeCode = 'AA'
 and a13.Dates = CONVERT(datetime, '2010-05-31 0:0:0', 120))
 and a11.Object='6650'
group by  a11.CompanyNumber,
                a11.DocumentType,
                a11.Subsidiary,
                a11.Object,
                a11.BusinessUnitID,
                a11.ExplanationDescription,
                a11.DocumentNumber


